#pragma once

namespace Common
{
	template<class T>
	inline DWORD PointerHash(const T* Key,DWORD C = 0)
	{
#define mix(a,b,c) \
		{ \
		a -= b; a -= c; a ^= (c>>13); \
		b -= c; b -= a; b ^= (a<<8); \
		c -= a; c -= b; c ^= (b>>13); \
		a -= b; a -= c; a ^= (c>>12);  \
		b -= c; b -= a; b ^= (a<<16); \
		c -= a; c -= b; c ^= (b>>5); \
		a -= b; a -= c; a ^= (c>>3);  \
		b -= c; b -= a; b ^= (a<<10); \
		c -= a; c -= b; c ^= (b>>15); \
	}

		DWORD A;
		DWORD B;
		A = B = 0x9e3779b9;
		// @todo win64: Adding a 64-bit pointer to a 32-bit dword here.  Use alternate hash function for _WIN64
		A += reinterpret_cast<UINT>(Key);
		mix(A,B,C);
		return C;

#undef mix
	}

}